# -*- coding: utf-8 -*-

'''
Created on 2010/02/26

@author: nagai
'''

import re
from kay.utils import to_local_timezone


from jinja2 import (
  environmentfilter, Markup, escape,
)

_paragraph_re = re.compile(r'(?:\r\n|\r|\n){2,}')

@environmentfilter
def date(environment, value):
    ret = to_local_timezone(value)
    result = ret.strftime('%Y/%m/%d')
    if environment.autoescape:
        result = Markup(result)
    return result

@environmentfilter
def datetime(environment, value):
    ret = to_local_timezone(value)
    result = ret.strftime('%Y/%m/%d %H:%M:%S %Z')
    if environment.autoescape:
        result = Markup(result)
    return result

@environmentfilter
def truefalse(environment, value):
    if value == True:
        result = u'<span class="true">%s</span>' % value
    else:
        result = u'<span class="false">%s</span>' % value
    if environment.autoescape:
        result = Markup(result)
    return result


if __name__ == '__main__':
    pass